using ECETCentralController.Communication;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using UnityEngine.UI;

public class AllControl : MonoBehaviour
{
    public Button allOn;
    public Button allOff;

    private string Ip = "192.168.1.99";
    private int port = 2430;
    void Start()
    {
        allOn.onClick.AddListener(() => {
            OpenAll();
        });
        allOff.onClick.AddListener(() => { 
            CloseAll();
        });
    }

    private void OpenAll()
    {
        new Thread(() => {

            UDPSender.SendString(Ip, port, "start_Light");
            Thread.Sleep(5000);

            UDPSender.SendString(Ip, port, "start_Screen");
            Thread.Sleep(5000);

            //UDPSender.SendString(Ip, port, "start_Projector");
            //Thread.Sleep(1000);

            UDPSender.SendString(Ip, port, "start_Computer");
            Thread.Sleep(5000);

        }).Start();
    }
    private void CloseAll()
    {
        new Thread(() => {

            UDPSender.SendString(Ip, port, "stop_Computer");
            Thread.Sleep(5000);

            //UDPSender.SendString(Ip, port, "stop_Projector");
            //Thread.Sleep(1000);

            UDPSender.SendString(Ip, port, "stop_Screen");
            Thread.Sleep(5000);

            UDPSender.SendString(Ip, port, "stop_Light");
            Thread.Sleep(5000);

        }).Start();
    }
    void Update()
    {
        
    }
}
